package com.hwadee.backend.entity.HealthRecord;

import lombok.Getter;
import lombok.Setter;

import java.sql.Date;

@Setter
@Getter
public class MedicalExamReport extends HealthRecord {
    // 异常指标
    private String abnormalIndicators;
    // 病情
    private String condition;
    // 医嘱
    private String medicalAdvice;
    // 体检机构
    private String examinationInstitution;
    // 体检医生
    private String examinationDoctor;
    // 备注
    private String remarks;

    public MedicalExamReport() {}

    public MedicalExamReport(int recordId, Date recordDate, String recordType, String detail) {
        super(recordId, recordDate, recordType, detail);
        splitDetail(detail);
        super.setDetail(null); // 将 detail 置为空值
    }

    /**
     * 从 detail 字符串中解析异常指标、病情、医嘱、体检机构、体检医生和备注
     * @param detail 包含异常指标、病情、医嘱、体检机构、体检医生和备注的字符串，用 | 分隔
     */
    private void splitDetail(String detail) {
        String[] parts = detail.split("\\|");
        if (parts.length >= 1) {
            this.abnormalIndicators = parts[0];
        }
        if (parts.length >= 2) {
            this.condition = parts[1];
        }
        if (parts.length >= 3) {
            this.medicalAdvice = parts[2];
        }
        if (parts.length >= 4) {
            this.examinationInstitution = parts[3];
        }
        if (parts.length >= 5) {
            this.examinationDoctor = parts[4];
        }
        if (parts.length >= 6) {
            this.remarks = parts[5];
        }
    }

}